package com.xianyu.open.restclient.config;

import org.springframework.http.HttpMethod;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 *
 * @author bailinan
 * @date 2018/6/16
 */
public class MethodInfo {
    /**
     *  接口生命的请求url
     */
    private String url;

    /**
     *  真正请求的请求url
     */
    private String relUrl;

    /**
     * 请求方法
     */
    private HttpMethod httpMethod;

    /**
     * 请求参数  get、post参数
     */
    private Map<String, Object> requestParam = new HashMap<>();

    /**
     * 请求头
     */
    private Map<String, String> requestHeader = new HashMap<>();

    /**
     * 请求体 部位null时请求头加上application/json
     */
    private Object requestBody;

    /**
     * restful api url参数
     */
    private Map<String, Object> uriVariables = new LinkedHashMap<>();

    /**
     * 相应体类型
     */
    private Class<?> responseType;

    /**
     * 完全响应数据的泛型参数
     */
    private Class<?> responseEntityType;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public HttpMethod getHttpMethod() {
        return httpMethod;
    }

    public void setHttpMethod(HttpMethod httpMethod) {
        this.httpMethod = httpMethod;
    }

    public Map<String, Object> getRequestParam() {
        return requestParam;
    }

    public Map<String, String> getRequestHeader() {
        return requestHeader;
    }

    public Object getRequestBody() {
        return requestBody;
    }

    public void setRequestBody(Object requestBody) {
        this.requestBody = requestBody;
    }

    public Map<String, Object> getUriVariables() {
        return uriVariables;
    }

    public Class<?> getResponseType() {
        return responseType;
    }

    public void setResponseType(Class<?> responseType) {
        this.responseType = responseType;
    }

    public String getRelUrl() {
        return relUrl;
    }

    public void setRelUrl(String relUrl) {
        this.relUrl = relUrl;
    }

    @Override
    public String toString() {
        return "MethodInfo{" +
                "url='" + url + '\'' +
                ", relUrl='" + relUrl + '\'' +
                ", httpMethod=" + httpMethod +
                ", requestParam=" + requestParam +
                ", requestHeader=" + requestHeader +
                ", requestBody=" + requestBody +
                ", uriVariables=" + uriVariables +
                ", responseType=" + responseType +
                ", responseEntityType=" + responseEntityType +
                '}';
    }

    public Class<?> getResponseEntityType() {
        return responseEntityType;
    }

    public void setResponseEntityType(Class<?> responseEntityType) {
        this.responseEntityType = responseEntityType;
    }
}
